﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace PMC
{
    /// <summary>
    /// Generic exception for duplicate name for a property where it's not allowed
    /// </summary>
    /// <typeparam name="T">Object type that causes the exception</typeparam>
    [Serializable]
    public class DuplicateNameException<T> : Exception
    {
        public T Object { get; set; }

        //
        // For guidelines regarding the creation of new exception types, see
        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
        // and
        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
        //

        public DuplicateNameException()
        {
        }

        public DuplicateNameException(string message) : base(message)
        {
        }

        public DuplicateNameException(string message, Exception inner) : base(message, inner)
        {
        }

        protected DuplicateNameException(
            SerializationInfo info,
            StreamingContext context) : base(info, context)
        {
        }

        public DuplicateNameException(string message, Exception innerException, T obj)
            : base(message, innerException)
        {
            Object = obj;
        }
    }
}
